<?php

  // Retrieve the file id from the request. This code would typically
  // have some error handling to cope with invalid input.
  $fileId = $_REQUEST["fileId"];

  // NOTE: IE will cache the content type, so after an error this
  // may not work until you restart IE.
  header('Content-Type', 'application/xml');

  // Prevent the browser from caching the output of this script.
  // This is needed as the XML may have been changed since last request.
  date_default_timezone_set('UTC');
  header('Expires', date('r', 0));

  // This code would typically interact with some sort of database.
  $path = realpath("../documents/$fileId");
  $document = new DOMDocument;
  $document->load($path);
  echo $document->saveXML();
